#{extends '/include/main.html' /}

<div>
	<form action="@@{CoreTableController.list()}">
		<input type="text" name="name"/>
		<select name="userid" >
			#{list items : users, as : 'user'}
				<option value="${user.id}">${user.name}</option>
			#{/list}
		</select>
		<input type="submit" value="查询"/>
	</form>
</div>
<table id="result">
	<thead>
		<tr>
			<th>序号</th>
			<th>表名</th>
			<th>维护人员</th>
			<th>修改</th>
		</tr>
	</thead>
	<tbody>
		#{if paged.items.size() < 1}
			#{emptyContent number:4 /}
		#{/if}
		#{else}
			#{list items : paged.items, as : 'table'}
				<tr>
					<td>${table.id}</td>
					<td>${table.name}</td>
					<td>${table.user.name}</td>
					<td><input type="button" class="result-table" value="修改" tableid="${table.id}"/></td>
				</tr>
			#{/list}
		#{/else}
	</tbody>
</table>

<form action="@@{CoreTableController.save()}" method="post">
	<input type="text" name="name" />
	<select name="userid" >
		#{list items : users, as : 'user'}
			<option value="${user.id}">${user.name}</option>
		#{/list}
	</select>
	<input type="submit" />
</form>
	
<script>
	$(function() {
		//create user
		var users = {};
		#{list items : users, as : 'user'}
			users['${user.id}'] = {
				name : "${user.name}",
				id : "${user.id}"
			}
		#{/list}

		$(".result-table").click(function() {
			var userid = $(this).attr("tableid");
			var user = users[userid];
			if (!user) {
				return;
			}
			
		});
	})
</script>